# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=dcc
pkgver=2.3.168
pkgrel=0
pkgdesc="Distributed Checksum Clearinghouses or DCC spam filter"
url="https://www.dcc-servers.net/dcc/"
arch="all"
license="custom"
pkgusers="dcc"
pkggroups="dcc"
makedepends="libmilter-dev"
subpackages="$pkgname-dccd $pkgname-dccifd $pkgname-dccm
	$pkgname-extras $pkgname-openrc $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://www.dcc-servers.net/src/dcc/old/dcc-$pkgver.tar.Z
	10-$pkgname-alpine.patch
	20-$pkgname-config.patch
	$pkgname.confd
	$pkgname.initd
"
install="$pkgname.pre-install $pkgname.post-install $pkgname.post-deinstall"

options="!check"

_p=var/dcc/libexec

prepare() {
	chmod 755 configure
	chmod 644 include/dcc_types.h include/dcc_config.h.in homedir/dcc_conf.in LICENSE
	default_prepare
}

build() {
	./configure \
		--with-installroot="$pkgdir" \
		--bindir="/usr/bin" \
		--mandir="/usr/share/man" \
		--with-uid=dcc
	make
}

package() {
	make install

	cd "$pkgdir"
	install -Dm 755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	install -Dm 644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
	install -Dm644 "$builddir"/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

	chmod 755 "$pkgdir"/var/dcc/libexec/dccsight
	cd "$pkgdir"/usr/bin
	chmod 755 cdcc dccproc
}

dccd() {
	pkgdesc="$pkgdesc (dccd server with grey listing)"
	depends="dcc"

	amove "$_p"/dccd "$_p"/start-dccd "$_p"/stop-dccd "$_p"/start-grey \
	"$_p"/dump-clients "$_p"/dblist "$_p"/dccsight
}

dccifd() {
	pkgdesc="$pkgdesc (dccifd server)"
	depends="dcc"

	amove "$_p"/dccifd "$_p"/start-dccifd
}

dccm() {
	pkgdesc="$pkgdesc (dccm server)"
	depends="dcc"

	amove "$_p"/dccm "$_p"/start-dccm
}

extras() {
	pkgdesc="$pkgdesc (dcc user commands)"
	depends="dcc"

	amove "$_p"/updatedcc "$_p"/uninstalldcc usr/bin/dccproc usr/bin/dccif-test
}

sha512sums="52a9671ba355a2d3e82246c3b5cf3875148d48bd314371d9e608643a59922becdf024b880e4bd37f6e36aa50830110600960ffa7a3ddd69ed7239bfc0578f141  dcc-2.3.168.tar.gz
8efe22be50da74abdf8fe26de028f13d7ee572c0f1fcfb174bcd8083523c0c5d2b0a5c2580d77d031c23f5ce728e045a6ba8ef9069a19cc6bcfe865142849d41  10-dcc-alpine.patch
8f7455cb8d49f26688fb8110c1a75311d9a8365e384dedbad7ab48bccdce6c0114f0c22d2024d05ab31d7ae5cdacf96972d8a7c0c361b767bde6532e1d9a94c7  20-dcc-config.patch
14a5d890ecff4081b369b26308d6225ab06d535f159ac59f6554335788bab4684717118f69cbe256075f57af2fc27639a5bcc6ab1bded3590e19cb3b5094ccb8  dcc.confd
a685383af856ea00be0333e4eccf1a8cd8869a286e28c706fb5f296b1e3b1612053f031963524207f614dae3847c165a067ec028dd5fce4f8c8c0f126388ff90  dcc.initd"
